<template>
	<view class="tab-control">
		<view class="tab-control-item" v-for="(item,index) in titles" :class="{'active':IndexPointer==index}"
			@tap="itemClick(index)">
			<text>{{item}}</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				IndexPointer: 0,
			};
		},
		props: {
			titles: {
				type: Array,
				default () {
					return []
				}
			},
		},
		methods: {
			itemClick(index) {
				this.IndexPointer = index;
				this.$emit('itemClick', index);

			}
		}
	}
</script>

<style lang="scss" scoped>
	.tab-control {
		display: flex;
		text-align: center;
		font-size: 28upx;
		height: 80upx;
		line-height: 80upx;
		padding-top: 10upx;
		background-color: #ffffff;

	}

	.tab-control-item {
		flex: 1;
	}

	.active {
		color: #3c9cff;

		text {
			border-bottom: 3px solid #3c9cff;
			padding: 5px;
		}
	}
</style>
